from utility import *



def find_potential_server(servers, task):
    for s in servers:
        if s.check_resource_limit(task):
            return s
    return None



def first_fit(tasks):
    servers = []
    for t in tasks:
        potential_server = find_potential_server(servers, t)
        if potential_server == None:
            new_server = create_sample_server()
            new_server.add_task(t)
            servers.append(new_server)
        else:
            potential_server.add_task(t)
    return servers